<%@ page import="com.opensymphony.xwork2.util.ValueStack" %>
<%@ page import="exam.AnswerPaperInfo" %>
<%@ page import="java.util.List" %>
<%@ page import="question.QuestionUtils" %>
<%@ page import="utils.TextUtils" %>
<%@ page import="examinee.ExamineeInfo" %>
<%@ page import="account.AccountUtils" %>
<%@ page import="utils.Var" %>
<%@ page import="exam.TestPaperInfo" %>
<%@ page import="exam.ExamVar" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    if (!AccountUtils.hasRight(session, Var.RIGHT_EXAM)) throw new Exception("deny!");

    ValueStack vs = (ValueStack) request.getAttribute("struts.valueStack");
    TestPaperInfo tinfo = (TestPaperInfo) vs.findValue("tinfo");
    ExamineeInfo einfo = (ExamineeInfo) vs.findValue("einfo");

    boolean isCheat = tinfo.getCheat() == 1;

    boolean isEnd = tinfo.getState() == ExamVar.STATE_END;
    boolean isControlDetail = AccountUtils.hasRight(session, Var.RIGHT_CONTROL_DETAIL);
    boolean isShowAnswer = isEnd || isControlDetail;

    List<AnswerPaperInfo> alist = (List<AnswerPaperInfo>) vs.findValue("alist");
    int score = 0;
    for (AnswerPaperInfo info : alist)
        if (info.getAnswer() != null && info.getAnswer().equals(info.getStandardAnswer()))
            score += QuestionUtils.getValue(info.getTx());
%>
<h2 class="title info">
    <span>准考证号：</span><%=einfo.getZkzh()%>
    <span>姓名：</span><%=einfo.getEname()%>
    <span>分数：</span><%=score%>
    <%
        if (isCheat) {
    %>
    <span>作弊</span>
    <%
        }
    %>
    <a href="javascript:void(0)" onClick="printScore(<%=tinfo.getTid()%>)">打印</a>
</h2>
<!--查询结果列表-->
<table cellpadding="0" cellspacing="0" width="100%" class="admin-table" style="margin:0;margin-bottom:5px;">
    <thead>
    <tr>
        <th style="width:40px;"><span class="first"></span>顺序</th>
        <th width="560">试题内容</th>
        <th style="width:80px">考试答案</th>
        <th style="width:80px">标准答案</th>
        <th style="width:40px;" class="last">结果</th>
    </tr>
    </thead>
    <tbody>
    <tr>
        <td colspan="5" style="padding:0;">

            <div style="height:320px; overflow:hidden;overflow-y:scroll; width:100%;">
                <table cellpadding="0" class="admin-table" width="100%" cellspacing="0" style="margin:0;">
                    <tbody>
                    <%
                        for (int i = 1; i <= alist.size(); i++) {
                            AnswerPaperInfo info = alist.get(i - 1);
                    %>
                    <tr>
                        <td style="width:40px;" class="first"><%=i%>
                        </td>
                        <td width="560"><%=info.getContent() == null || info.getContent().length() == 0 ? "&nbsp;" : TextUtils.html(info.getContent())%>
                        </td>
                        <td style="width:80px"><%=info.getAnswer() == null || info.getAnswer().length() == 0 ? "&nbsp;" : QuestionUtils.getAnswer(info.getTx(), info.getAnswer())%>
                        </td>
                        <td style="width:80px"><%=!isShowAnswer?"&nbsp;":QuestionUtils.getAnswer(info.getTx(), info.getStandardAnswer())%>
                        </td>
                        <td style="width:40px;" class="last"><%=info.getStandardAnswer().equals(info.getAnswer()) ? "对" : "错"%>
                        </td>
                    </tr>
                    <%
                        }
                    %>
                    </tbody>
                </table>
            </div>
        </td>
    </tr>
    </tbody>
</table>
<button type="button" class="blue" onclick="kswindow.close()"><span></span>关闭</button>